import java.util.Scanner;
import java.math.*;
public class 全排列 {
    static  int N = 10;
    static int n = 9;
    static int target;
    static int count;//计数器
    static int[] arr = new int[N];
    static boolean[] used= new boolean[N];//false未选，true表示选了

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        target = s.nextInt();
        dfs(1);

        System.out.println(count);
    }

    private static int calc(int l,int r) {
        int sum = 0;
        int j=0;
        for(int i = l; i<=r; i++) {
            sum=sum*10+arr[i];
        }
        return sum;
    }

   private static void dfs(int u) {
        if(u>n) {
            for(int i=1;i<=n-2;i++) {
               for(int j=i+1; j<=n-1;j++) {
                   int a = calc(1,i);
                   int b = calc(i+1,j);
                   int c = calc(j+1, n);
                   if(a*c+b == target*c) {
                       count++;
                   }
               }
            }
            return ;
        }
        //全排列
        for(int i=1;i<=n;i++) {
            if(!used[i]) {
                arr[u] = i;
                used[i] = true;

                dfs(u + 1);
                arr[u] = 0;
                used[i] = false;
            }
        }
   }


}
